package com.fyy.content.api;

import com.fyy.content.model.dto.AddOrUpdateTeachPlanDTO;
import com.fyy.content.model.dto.TeachPlanDTO;
import com.fyy.content.service.TeachPlanService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fyy
 * @version 1.0
 * @description 课程计划相关接口
 * @date 2024/7/21 11:43
 */
@RestController
public class TeachPlanController {

    @Autowired
    private TeachPlanService teachPlanService;

    @ApiOperation("查询课程计划树形结构")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachPlanDTO> getTreeNodes(@PathVariable Long courseId) {
        return teachPlanService.selectTreeNodes(courseId);
    }

    @ApiOperation("新增或更新课程计划")
    @PostMapping("/teachplan")
    public void addOrUpdateTeachPlan(@RequestBody AddOrUpdateTeachPlanDTO addOrUpdateTeachPlanDTO) {
        teachPlanService.addOrUpdate(addOrUpdateTeachPlanDTO);
    }

    @ApiOperation("删除课程计划")
    @DeleteMapping("/teachplan/{teachPlanId}")
    public String deleteById(@PathVariable Long teachPlanId) {
        return teachPlanService.deleteById(teachPlanId);
    }
}
